package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 邓大帅
 * Date: 2024-01-10
 * Time: 20:30
 */
public class Computer {
    public void open() {
        System.out.println("打开电脑");
    }
    public void close() {
        System.out.println("关闭电脑");
    }

    public void useDevice(IUSB usb) {
        usb.openDevice();
        if (usb instanceof Mouse) {
            Mouse mouse = (Mouse) usb;
            mouse.click();
        }else if (usb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.inPut();
        }
        usb.closeDevice();
    }
}
